using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("GameObject")]
	[Description("Note that this is very slow")]
	public class FindObjectOfType : ActionTask
	{
		public BBString type = new BBString
		{
			value = "Camera"
		};

		[BlackboardOnly]
		public BBGameObject saveGameObjectAs;

		protected override void OnExecute()
		{
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject gameObject in array)
			{
				if (gameObject.GetComponent(type.value) != null)
				{
					saveGameObjectAs.value = gameObject;
					EndAction(true);
					return;
				}
			}
			saveGameObjectAs.value = null;
			EndAction(false);
		}
	}
}
